<template>
	<el-form :model="form" :rules="rules" :disabled="mode=='show'" ref="dialogForm" label-width="80px" label-position="top">
		<el-row :gutter="20">
			<el-col :span="12">
				<el-form-item label="平台微信用户" prop="user_id" >
					<el-input v-model="form.user_id" clearable :disabled="mode=='edit'"></el-input>
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="姓名" prop="name" >
					<el-input v-model="form.name" clearable></el-input>
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="电话" prop="tel" >
					<el-input v-model="form.tel" clearable></el-input>
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="代理类型" prop="agent_type" >
					<el-radio-group v-model="form.agent_type" :disabled="mode=='edit'">
						<el-radio v-model="form.agent_type" label="1">市代</el-radio>
						<el-radio v-model="form.agent_type" label="2">区代</el-radio>
					</el-radio-group>
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="代理地区" prop="agent_region" >
					<el-input v-model="form.agent_region" clearable :disabled="mode=='edit'"></el-input>
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="申请理由" prop="desc" >
					<el-input v-model="form.desc" clearable></el-input>
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="审核状态" prop="status" >
					<el-select v-model="form.status" placeholder="请选择">
						<el-option
							v-for="item in statusData"
							:key="item.value"
							:label="item.label"
							:value="item.value">
						</el-option>
					</el-select>
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="单个视频转发数" prop="forwarding" >
					<el-input v-model="form.forwarding" clearable></el-input>
					<div class="el-form-item-msg" data-v-b33b3cf8="">0则使用平台默认转发次数</div>
				</el-form-item>
			</el-col>
<!--			<el-col :span="12">-->
<!--				<el-form-item label="电话" prop="time_type">-->
<!--					<el-radio-group v-model="form.time_type">-->
<!--						<el-radio v-model="form.time_type" label='1'>永久</el-radio>-->
<!--						<el-radio v-model="form.time_type" label='2'>自定义天数</el-radio>-->
<!--					</el-radio-group>-->
<!--				</el-form-item>-->
<!--			</el-col>-->
		</el-row>

	</el-form>
</template>

<script>
export default {
	props: {
		mode: { type: String, default: "add" }
	},
	data() {
		return {
			//表单数据
			form: {
				agent_region: "黑龙江省-哈尔滨市",
				agent_type: "1",
				// create_time: "2021-10-26 11:09:19",
				desc: "",
				forwarding: 0,
				id: '',
				name: "一样一样",
				pid: 0,
				status: 1,
				tel: "15674086925",
		        user_id: 40
			},

			//验证规则
			rules: {
				user_id:[
					{type:'number',required: true, message: '用户不能为空'}
				],
				name:[
					{required: true, message: '请输入套餐名称'}
				],
				tel: [
					{required: true, message: '请输入电话'}
				],
				desc: [
					{required: true, message: '请输入申请理由'}
				],
				status: [
					{required: true, message: '请选择审核状态'}
				],
				forwarding: [
					{required: true, message: '请输入单个视频转发数'}
				],

			},
			statusData:[
				{label:'未审核',value:0},
				{label:'审核通过',value:1},
				{label:'审核不通过',value:2},

			],

		}
	},
	mounted() {
		if(this.mode != 'add'){
			this.rules.password = []
			this.rules.password2 = []
		}
		// this.getGroup()
	},
	methods: {

		//表单提交方法
		submit(callback){
			this.$refs.dialogForm.validate((valid) => {
				if (valid) {
					callback(this.form)
					console.log(this.form)
				}else{
					return false;
				}
			})
		},
		//表单注入数据
		setData(data){
			console.log('注入数据',data)

            data.agent_type = data.agent_type==1?"1":"2"
			//可以和上面一样单个注入，也可以像下面一样直接合并进去
			Object.assign(this.form, data)
		}
	}
}
</script>

<style>
</style>
